package com.extra;

import java.util.Arrays;
import java.util.HashMap;

public class Solution724 {
    public int pivotIndex(int[] nums) {
        int sum = 0;
        for (int x : nums) {
            sum += x;
        }
        int left = 0;
        int right = 0;
        for (int i = 0; i < nums.length; i++) {
            left += nums[i];
            right = sum - left + nums[i];
            if (right == left) return i;
        }
        return -1;
    }
}
